Repository navigation
Conversation
…d actions Adds an A2UI screen to the example, opened from the chat's app bar, that chats with a new `a2ui` agent of the example runtime: - An A2UI v0.9 catalog (ItemCatalog) with ItemList, ItemCard and RangeFilter next to the basic Column, Row, Text and Divider, advertised and rendered with CopilotA2ui. - Each ItemCard is bound to its own /items/<index>, so the refresh_item server tool's single updateDataModel of /items/2 rebuilds that card only. Pins live in the surface's data (/pinnedIds) and RangeFilter writes /filter/max, so the refresh action's context carries local state. - The runtime turns the A2UI middleware on for the a2ui agent (injectA2UITool) and adds the fixed-schema refresh_item tool. - The recorder gains an item_refresh case, recorded from runtimes 1.79 and 1.91 into example/test/fixtures, which the page test replays end to end. A live test runs the flow against a real runtime, skipped unless COPILOTKIT_LIVE_RUNTIME_URL is set. - Docs: an A2UI quickstart in the copilotkit_flutter README, an A2UI section and checklist in the example README. Closes #248 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Status
READY
Description
Closes #248. Last PR of the A2UI stack (#71). It builds on #257 (
test/a2ui-recorded-fixtures).The example gets an A2UI screen. An app bar button in the chat opens it. The screen chats with a new
a2uiagent of the example runtime.App (
example/lib/a2ui/)ItemCatalogis an A2UI v0.9 catalog withItemList,ItemCardandRangeFilter. It also holds the basicColumn,Row,TextandDivider, because a v0.9 surface draws on one catalog. Each component is a class that holds its schema (CommonSchemas) and its builder. Its widget is plain Flutter, inwidgets/.A2uiPagewraps the chat inCopilotA2ui(protocol: A2uiProtocol.v0_9, catalogs: ...). It reuses the chat'sMessageListandComposer. An empty chat offers the "three suggestions under $30" prompt./items/<index>. Therefresh_itemupdate of/items/2therefore rebuilds that card and no other. The replay test checks this: theItemCardwidgets of cards 1 and 2 are the same instances before and after the refresh./pinnedIds, and the card toggles its ownitemIdthere.RangeFilterwrites/filter/max. The refresh action's context,{itemIndex, pinnedIds, filterMax}, reads both.Runtime (
example/tool/runtime/)server.tssetsa2ui: { injectA2UITool: true, agents: ["a2ui"] }, so the default and document agents are unchanged.a2ui_agent.tsadds thea2uiagent and the fixed-schema server toolrefresh_item. The tool returns{"a2ui_operations": [updateDataModel{path: "/items/<i>"}]}. It has tests ina2ui_agent.test.ts, whichnpm testruns, and it addszod3.25.76 as a direct dependency (already in the lockfile).item_refreshcase for this flow. It records with the example's agent id and catalog context intoexample/test/fixtures/a2ui/{1.79.0,1.91.0}/. Its fixtures are kept apart from the SDK's, socopilotkit_flutter's fixture test still covers the same cases.Tests
test/a2ui/widgets/a2ui_page_test.dartreplays both recordings through the real client and page (test/helpers/a2ui_wire_replay.dartis copied fromcopilotkit_flutter). It checks that:context: {itemIndex: 2, pinnedIds: ["a","b"], filterMax: 25};test/a2ui_live_test.dartruns the same flow against a real runtime and model. It is skipped unlessCOPILOTKIT_LIVE_RUNTIME_URLis set (ADR 0015), so it never runs on CI.Docs.
docs/flutter-quickstart.mdxdoes not exist in this repo. The quickstart went where the earlier A2UI docs are: "Quickstart: a custom catalog" in thecopilotkit_flutterREADME (catalog, attach, runtime, actions). The example README has an "A2UI" section (files, flow, how to switch to v1.0, tests) and a checklist entry. ARCHITECTURE.md, CONTRIBUTING.md and the root README's demo list are updated.Deviations from the issue, for review
pinnedandonTogglePinbecameitemIdandpinnedIds, a list bound to/pinnedIdsthat the card adds itself to or removes itself from. In v0.9, a component's action can only start an agent turn or call a basic function. A pin sent to the agent would start one turn per pin, and a second pin during the first turn would be dropped. Keeping the pins in the surface's data is what lets the action's context carry them.ItemListtakes card ids, not a template. The cards of a template read paths relative to the list, so the agent can't give each card's action its ownitemIndex. A template still renders.Checks:
flutter analyze,dart format, cspell anddart doc(0 warnings) are clean. Tests of all three packages pass at 100% coverage, andnpm testinexample/tool/runtimepasses (14 tests).flutter build web --wasm --dart-define=RUNTIME_URL=http://localhost:8200/api/copilotkitbuilds.Reviewer step: the live flow. It needs a model key, so it was not run.
To run the same flow as a test against that runtime:
Type of Change
🤖 Generated with Claude Code